#lang racket
(require "rename-mutable-pair-ops.rkt")

(define x (list 'a 'b))

(define y (list 'c 'd))

(define z (append x y))

(print-list z)
;(a b c d)

(print-list (cdr x))
;(b)

(define (last-pair x)
  (if (null? (cdr x))
      x
      (last-pair (cdr x))))

(define (append! x y)
  (set-cdr! (last-pair x) y)
  x)

(define w (append! x y))

(print-list w)
;(a b c d)

(print-list (cdr x))
;(b c d)